Print a message when a command receives a signal
authorAlex Crichton <alex@alexcrichton.com>
Fri, 25 Jul 2014 22:38:06 +0000 (15:38 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 25 Jul 2014 22:38:58 +0000 (15:38 -0700)
Receiving a signal is normally indicative of violent termination, so the
subcommand can't be relied upon to have printed some status information. As a
result, signals now have some extra errors printed to stderr when they fail.

Closes #261. The actual signal is still a bug, but it's an upstream rust bug.

src/bin/cargo.rs
src/cargo/core/registry.rs
src/cargo/core/resolver.rs
src/cargo/ops/cargo_rustc/fingerprint.rs

index 81c5cc13b5880c7badcc778884e8f5b104191d12..33ab1f9e6411a11c24d8f1877f0f9e511d26e1c5 100644 (file)
@@ -94,9 +94,13 @@ fn execute() {
 
             match command {
                 Ok(ExitStatus(0)) => (),
-                Ok(ExitStatus(i)) | Ok(ExitSignal(i)) => {
+                Ok(ExitStatus(i)) => {
                     handle_error(CliError::new("", i as uint), &mut shell(false))
                 }
+                Ok(ExitSignal(i)) => {
+                    let msg = format!("subcommand failed with signal: {}", i);
+                    handle_error(CliError::new(msg, 1), &mut shell(false))
+                }
                 Err(_) => handle_error(CliError::new("No such subcommand", 127), &mut shell(false))
             }
         }
@@ -105,7 +109,7 @@ fn execute() {
 
 fn process(args: Vec<String>) -> (String, Vec<String>) {
     let mut args = Vec::from_slice(args.tail());
-    let head = args.shift().unwrap_or("--help".to_string());
+    let head = args.remove(0).unwrap_or("--help".to_string());
 
     (head, args)
 }
index e5752e33668a35f1f51c6a91c2994f85540c8eed..db3425ecdf78f92345e95bbad3ba1218064139ba 100644 (file)
@@ -1,4 +1,3 @@
-use std::collections::HashMap;
 use std::vec::Vec;
 use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package};
 use util::{CargoResult, ChainError, Config, human};
index 4d7411bf6e49abe72b9b112f77f480c1c575f859..c693754cf969a2e2282820733536e993ae07d448 100644 (file)
@@ -1,6 +1,5 @@
 use std::collections::HashMap;
 use std::fmt;
-use serialize::{Encodable, Encoder};
 use util::graph::{Nodes,Edges};
 
 use core::{
index 6d2c0f3d94f5e769a169ebaabda0372f1899970e..4eb7f5719367c742b2d7258425706c3c9f732d23 100644 (file)
@@ -5,7 +5,7 @@ use std::io::{fs, File};
 use core::{Package, Target};
 use util;
 use util::hex::short_hash;
-use util::{CargoResult, Fresh, Dirty, Freshness, Config};
+use util::{CargoResult, Fresh, Dirty, Freshness};
 
 use super::job::Job;
 use super::context::Context;